package com.ysqcould.approval.service.impl;


import cn.hutool.core.util.ObjectUtil;
import com.ysqcould.approval.domain.Conference;
import com.ysqcould.approval.domain.vo.ConferenceVo;
import com.ysqcould.approval.mapper.ConferenceMapper;
import com.ysqcould.approval.service.IConferenceService;
import com.ysqcould.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 会议Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-06-29
 */
@Service
public class ConferenceServiceImpl implements IConferenceService
{
    @Autowired
    private ConferenceMapper conferenceMapper;

    /**
     * 查询会议
     * 
     * @param id 会议主键
     * @return 会议
     */
    @Override
    public Conference selectConferenceById(Long id)
    {
        return conferenceMapper.selectConferenceById(id);
    }

    /**
     * 查询会议列表
     *
     * @param conference 会议
     * @return 会议
     */
    @Override
    public List<ConferenceVo> selectConferenceList(Conference conference)
    {
        List<ConferenceVo> vos = conferenceMapper.selectConferenceList(conference);
        vos.forEach(p->{
            if (ObjectUtil.isNotEmpty(p.getPcUrl())){
                p.setPcUrlList(p.getPcUrl().split(";"));
            }
        });
        return vos;
    }

    /**
     * 新增会议
     * 
     * @param conference 会议
     * @return 结果
     */
    @Override
    public int insertConference(Conference conference)
    {
        conference.setCreateTime(DateUtils.getNowDate());
        return conferenceMapper.insertConference(conference);
    }

    /**
     * 修改会议
     * 
     * @param conference 会议
     * @return 结果
     */
    @Override
    public int updateConference(Conference conference)
    {
        conference.setUpdateTime(DateUtils.getNowDate());
        return conferenceMapper.updateConference(conference);
    }

    /**
     * 批量删除会议
     * 
     * @param ids 需要删除的会议主键
     * @return 结果
     */
    @Override
    public int deleteConferenceByIds(Long[] ids)
    {
        return conferenceMapper.deleteConferenceByIds(ids);
    }

    /**
     * 删除会议信息
     * 
     * @param id 会议主键
     * @return 结果
     */
    @Override
    public int deleteConferenceById(Long id)
    {
        return conferenceMapper.deleteConferenceById(id);
    }
}
